/*     */ package com.zimbra.cs.convert;
/*     */ 
/*     */ import java.io.UnsupportedEncodingException;
/*     */ import java.nio.charset.Charset;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Collections;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.StringTokenizer;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DocumentText
/*     */ {
/*     */   public static DocumentText EMPTY;
/*     */   private Map mAttrs;
/*     */   private String mContentTypes;
/*     */   private byte[] mContentBytes;
/*     */   private String mCharEncoding;
/*     */   
/*     */   static
/*     */   {
/*     */     try
/*     */     {
/*  40 */       EMPTY = new DocumentText("".getBytes("UTF-8"), "UTF-8", Collections.EMPTY_MAP, "text/plain");
/*     */     }
/*     */     catch (UnsupportedEncodingException e) {}
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public DocumentText(byte[] bytes, String charEncoding, Map attrs, String contentTypes)
/*     */     throws UnsupportedEncodingException
/*     */   {
/*  62 */     this.mAttrs = attrs;
/*  63 */     this.mContentTypes = contentTypes;
/*  64 */     if ((charEncoding != null) && (!Charset.isSupported(charEncoding)))
/*  65 */       throw new UnsupportedEncodingException("unsupported char encoding: " + charEncoding);
/*  66 */     this.mContentBytes = bytes;
/*  67 */     this.mCharEncoding = charEncoding;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Map getAttrs()
/*     */   {
/*  74 */     return this.mAttrs;
/*     */   }
/*     */   
/*     */ 
/*     */   public String getContent()
/*     */   {
/*  80 */     if (this.mCharEncoding == null)
/*  81 */       return new String(this.mContentBytes);
/*     */     try {
/*  83 */       return new String(this.mContentBytes, this.mCharEncoding);
/*     */     }
/*     */     catch (UnsupportedEncodingException e) {}
/*  86 */     return "";
/*     */   }
/*     */   
/*     */   public byte[] getContentBytes()
/*     */   {
/*  91 */     return this.mContentBytes;
/*     */   }
/*     */   
/*     */   public String getCharEncoding() {
/*  95 */     return this.mCharEncoding;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public String getContentTypes()
/*     */   {
/* 102 */     return this.mContentTypes;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public List<String> getContentTypeList()
/*     */   {
/* 109 */     if ((this.mContentTypes == null) || ("".equals(this.mContentTypes))) {
/* 110 */       return Collections.emptyList();
/*     */     }
/* 112 */     List<String> a = new ArrayList();
/* 113 */     StringTokenizer st = new StringTokenizer(this.mContentTypes, ",");
/* 114 */     while (st.hasMoreTokens()) {
/* 115 */       a.add(st.nextToken().trim());
/*     */     }
/* 117 */     return a;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/convert/DocumentText.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */